import Vue from 'vue'
import VueRouter from 'vue-router'
import content_home from '../components/contents/content-home'
import nav_home from '../components/navs/nav-home'
import article_content from '../components/article/content'
import article_menu from '../components/article/menu'
import image_bed_upload from '../components/image-bed/image-bed-upload'
import content_article_list from '../components/article-list/article-list'
import nav_article_list from '../components/article-list/nav'

Vue.use(VueRouter)

// 防止重复导航报错
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

const routes = [
    {
        //首页路由
        path: '/',
        name: 'content_home',
        components: {
            // 控制router-view.name=content
            content: content_home,
            nav: nav_home
        }
    },{
        //全部文章
        path: '/article_list',
        name: 'article_list',
        components: {
            // 控制router-view.name=content
            content: content_article_list,
            nav: nav_article_list
        }
    },{
        // 文章
        path: '/article',
        name: 'article',
        components: {
            content: article_content,
            article_menu: article_menu,
        }
    }, {
        //图床
        path: '/image_bed',
        name: 'image_bed',
        component: image_bed_upload
    }
]

const router = new VueRouter({
    routes
})

export default router
